


# # 绑定到app上
#
#
#
# from flask import Flask
#
# from toutiao.config import Config,config_redis
#
# # from flask_cache import Cache
# # 实例
# # cache = Cache(config=config_redis)
#
# from toutiao.model.j import db
#
# def create_app():
#     app = Flask(__name__)
#     # app.config["SQLALCHEMY_DATABASE_URI"]=Config.DB_URL
#     #
#     # app.config['SQLALCHEMY_ECHO']=True
#     app.config.from_object(Config)
#
#     with app.app_context():
#         db.init_app(app)
#         db.create_all()
#
#     return app
#
#
# app = create_app()
# from toutiao.view.user import user_api
# app.register_blueprint(user_api)
# # cache = Cache(config=config_redis)
#
# if __name__ == '__main__':
#     # from model.db import db
#     # db.create_all()
#     app.run()
from flask import Flask

from toutiao.model.j import db

from toutiao.config import Config
# app = Flask(__name__)

from toutiao.cache.redis import redis_client,redis_client1



def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    redis_client.init_app(app)
    redis_client1.init_app(app)
    from toutiao.view.user import user_api
    app.register_blueprint(user_api)
    from toutiao.view.follow import relation_api
    app.register_blueprint(relation_api)
    app.secret_key = 'why would I tell you my secret key?'
    # 数据库初始化
    with app.app_context():
        db.init_app(app)
        db.create_all()

    # 注册路由
    return app


app = create_app()

if __name__ == '__main__':
    app.run()
